/*
 * @Descripttion: 商机品类
 * @version:
 * @Author: lehaixia
 * @Date: 2022-10-21 10:32:19
 * @LastEditors: lehaixia
 * @LastEditTime: 2023-06-02 10:19:31
 */
import request from '@/utils/request'

// 获取商机详情信息
export function getOptyDetail(id) {
  return request({
    url: `/app/v1/opty/${id}`,
    method: 'get'
  })
}

/**
 * 查询商机设计师
 * @param {Object} params optyId 商机ID
 * @returns
 */
export const queryDesignerByOptyId = async(params) => {
  const res = await request({
    url: `/app/v1/optyFollowUpUser/queryDesignerByOptyId`,
    method: 'get',
    params
  })
  return res && res.data
}

/**
 * 查询客户导购
 * @param {Object} params clueCustomerId 客户ID
 * @returns
 */
export const queryGuidByClueCustomerId = async(params) => {
  const res = await request({
    url: `/app/v1/clueFollowUpUser/queryGuidByClueCustomerId`,
    method: 'get',
    params
  })
  return res && res.data
}

// 获取商机品类信息
export const getOptyCategoryData = async(data) => {
  const res = await request(
    {
      url: '/app/v1/optyCategory/dis/page',
      method: 'post',
      data,
      headers: {
        'Permission-PerCode': 'opty_processing_dis',
        'Permission-App': 'top2-crm-app'
      }
    }
  )
  return res && res.data && res.data.records
}

// 查询当前经销商下配置的品类
export const getDistributorCategorySelection = async(params) => {
  const res = await request({
    url: `/app/v1/distributorConfig/getDistributorCategorySelection`,
    method: 'get',
    params
  })
  return res && res.data
}

/**
 * 添加商机品类
 * @param {Object} data
 * @returns
 */
export function addOptyCategory(data) {
  return request({
    url: '/app/v1/optyCategory/addOptyCategory',
    method: 'post',
    data,
    loading: true,
    message: '保存中'
  })
}

// 查询品类节点变更
export const getCategoryStageLine = async(optyCategoryId) => {
  const res = await request({
    url: `/app/v1/optyCategoryStageRecord/query/${optyCategoryId}`,
    method: 'get',
    loading: true, // 是否显示加载
    message: '正在加载' // 加载提示信息
  })
  return res && res.data
}

// 文件上传
export function uploadFile(data) {
  return request({
    url: '/app/v1/attachment/upload',
    method: 'post',
    data,
    headers: {
      // 添加请求头
      'Content-Type': 'multipart/form-data'
    },
    loading: false
    // message: '上传中'
  })
}

/**
 * 删除附件
 * @param {Array} data：id集合
 * @returns
 */
export function deleteByAttachmentUseIds(data) {
  return request({
    url: '/app/v1/attachment/deleteByAttachmentUseIds',
    method: 'DELETE',
    data,
    loading: true,
    message: '删除中'
  })
}

/**
 * 量尺分页
 * @param {Object} data
 * @returns
 */
export function getMeasureInfo(data) {
  return request({
    url: '/app/v1/measureInfo/page',
    method: 'post',
    data
  })
}

/**
 * 量尺保存
 * @param {Object} data
 * @returns
 */
export function saveMeasureInfo(data) {
  return request({
    url: '/app/v1/measureInfo/add',
    method: 'post',
    data,
    loading: true,
    message: '保存中'
  })
}

/**
 * 量尺 效果图 三视图分页
 *  * @param {String} url
 * @param {Object} data
 * @returns
 */
export function getImgInfo(url, data) {
  return request({
    url: url,
    method: 'post',
    data
  })
}

/**
 * 设计师分页查询方案
 * @param {Object} data
 * @returns
 */
export function queryMySchemeByPage(data) {
  return request({
    url: '/app/v1/scheme/queryMySchemeByPage',
    method: 'post',
    data
  })
}

/**
 * 绑定方案/更换方案
 *  @param {url} data
 * @param {Object} data
 * @returns
 */

export function bindScheme(url, data) {
  return request({
    url: `/app/v1/optyCategory/${url}`,
    method: 'post',
    data,
    loading: true,
    message: '保存中'
  })
}

/**
 * 查询绑定的方案
 * @param {Object} params
 * @returns
 */
export function queryBindScheme(params) {
  return request({
    url: '/app/v1/optyCategory/queryBindScheme',
    method: 'get',
    params
  })
}

/**
 * 效果图分页
 * @param {Object} data
 * @returns
 */
export function getDesignSketch(data) {
  return request({
    url: '/app/v1/designSketch/page',
    method: 'post',
    data
  })
}

/**
 * 三视图分页
 * @param {Object} data
 * @returns
 */
export function getAttachment(data) {
  return request({
    url: '/app/v1/attachment/page',
    method: 'post',
    data
  })
}

/**
 * 确认方案前检查
 * @param {Object} data
 * @returns
 */
export function confirmSchemeCheck(data) {
  return request({
    url: '/app/v1/optyCategory/confirmSchemeCheck',
    method: 'post',
    data
  })
}

/**
 * 确认方案
 * @param {Array} data
 * @returns
 */
export function confirmScheme(data) {
  return request({
    url: '/app/v1/optyCategory/confirmScheme',
    method: 'post',
    data
  })
}

/**
 * 预约到店
 * @param {Object} data
 * @returns
 */
export function inviteToStore(data) {
  return request({
    url: '/app/v1/optyCategory/inviteToStore',
    method: 'post',
    data,
    loading: true,
    message: '保存中'
  })
}

/**
 * 刷新效果图
 * @param {Object} data
 * @returns
 */
export function refreshDesignSketch(data) {
  return request({
    url: '/app/v1/designSketch/refresh',
    method: 'post',
    data
  })
}

/**
 * 获取批价
 * @param {Object} data
 * @returns
 */
export function getRatingPrice(params) {
  return request({
    url: '/app/v1/optyCategory/getRatingPrice',
    method: 'post',
    params,
    loading: true,
    message: '查询批价中...'
  })
}
